{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "vscode": {
     "languageId": "dotnet-interactive.fsharp"
    }
   },
   "outputs": [],
   "source": [
    "#r \"nuget: NuGet.Protocol, 6.2.1\"\n",
    "#r \"nuget: Plotly.NET, 3.0.0\"\n",
    "#r \"nuget: Plotly.NET.Interactive, 3.0.0\"\n",
    "#r \"nuget: LibGit2Sharp, 0.26.2\"\n",
    "#r \"nuget: BenchmarkDotnet, 0.13.1\"\n",
    "#r \"../../../../artifacts/bin/HistoricalBenchmark.Runner/Release/net7.0/HistoricalBenchmark.Runner.dll\"\n",
    "\n",
    "open HistoricalBenchmark.Runner\n",
    "\n",
    "let config =\n",
    "    {\n",
    "        RunConfig.Time = DateTime(2022, 7, 12, 8, 19, 0)\n",
    "        // Set to a valid local absolute path\n",
    "        BaseDir = \"d:/benchmarks\"\n",
    "        Parallelism = 3\n",
    "        ResultsSuffix = \"results\"\n",
    "        BuildLocalCodebases = false\n",
    "    }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "vscode": {
     "languageId": "dotnet-interactive.fsharp"
    }
   },
   "outputs": [],
   "source": [
    "// let newerVersion = findVersion \"40.0.1-preview.21352.5\"\n",
    "// let olderVersion = findVersion \"40.0.0\"\n",
    "// let newerRevision = NuGet.resolvePackageRevision newerVersion\n",
    "// let olderVersion = NuGet.resolvePackageRevision olderVersion\n",
    "\n",
    "// Find all commits between the two\n",
    "let newerRevision = \"cb3692bf5d5af46b075c50d4f802f09152fb6b67\"\n",
    "let olderRevision = \"4d330f37ae740adccd2586d568b6d45d2c408fad\"\n",
    "let cNewer, cOlder = Git.findCommit config newerRevision, Git.findCommit config olderRevision\n",
    "let versions =\n",
    "    Git.findCommitsBetweenInclusive config cOlder cNewer |> Seq.toList\n",
    "    |> Git.excludeBadCommits [\"679e11c533ad6c408723cf9b227a57be23fb51db\"]\n",
    "    |> List.map (fun c -> FCSVersion.Git c.Sha)\n",
    "// Fetch, build and run benchmarks for all of them\n",
    "Runner.runAll {config with ResultsSuffix = \"between_2_nuget_versions\"} versions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "vscode": {
     "languageId": "dotnet-interactive.fsharp"
    }
   },
   "outputs": [],
   "source": [
    "// Find two latest NuGet versions of FCS (including prereleases), run benchmarks and export results\n",
    "NuGet.allVersionsMetadata.Value()\n",
    "|> List.take 10\n",
    "|> List.map (fun metadata -> FCSVersion.NuGet metadata.Identity.Version)\n",
    "|> Runner.runAll {config with ResultsSuffix = \"10_latest_nuget_versions\"}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "vscode": {
     "languageId": "dotnet-interactive.fsharp"
    }
   },
   "outputs": [],
   "source": [
    "let versions =\n",
    "    [\n",
    "        FCSVersion.Local\n",
    "        FCSVersion.Git \"4edcbb45365f96d4858f438a556b93d4a32ae219\"\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"41.0.5-preview.22329.3\")\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"41.0.5\")\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"40.0.0\")\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"35.0.0\")\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"30.0.0\")\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"25.0.1\")\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"20.0.1\")\n",
    "        FCSVersion.NuGet (NuGet.findVersion \"13.0.0\")\n",
    "    ]\n",
    "    \n",
    "Runner.runAll {config with ResultsSuffix = \"sample_versions\"} versions"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "C#",
   "pygments_lexer": "csharp",
   "version": "9.0"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
